﻿using System;
using System.Runtime.Serialization;
using Flatland.GeneticProgramming.CoreTypes;

/**
* 
* Copyright (c) 2012 Anders Høst Kjærgaard | ahkj@itu.dk
* 
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, 
* including without limitation the rights to use, copy, modify, merge, publish, distribute, 
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial 
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

namespace Flatland.GeneticProgramming.Examples {
    /// <summary>
    /// Template for a GenoType implementation. It shows what member must at least be implemented for the template to be valid marked with.
    /// Examples can be found in the Examples namespace
    /// </summary>
    [Serializable]
    public class Template : GenoType {


        //********* Implement your Primitive. *************


// ReSharper disable CSharpWarnings::CS1591
        
        [Primitive] 
        public bool b;

        [Primitive] 
        public bool[] bools = new bool[3];

        [Primitive]
        public void MoveLeft() {
            Agent.SetDirection((float)Math.PI);
        }

        [Primitive]
        public bool SeesFood() {
            return Agent.SeesFood;
        }

        [Primitive]
        public bool SeesFood(bool b) {
            return Agent.SeesFood && b;
        }

        // ReSharper restore CSharpWarnings::CS1591

        /// <summary>
        /// Reports must expose a public parameterless constructor.
        /// </summary>
        public Template() { }

        /// <summary>
        /// Called when this genotype should act for the Agent.
        /// </summary>
        /// <param name="msg"></param>
        protected override void Act(ref string msg) {
            /************* Execute your the program with the Agent in Flatland ******************
             * 
             * Execute();
             * 
             */
        }

        /// <summary>
        /// When running GP this should return a fitness value.
        /// This is often done by setting variables combined with a call to Execute that executes the genetic code. </summary>
        /// <returns></returns>
        public override double Fitness() {
            //var fitness = Execute(); 
            return 42;
        }

        /// <summary>
        /// Reports are clonable.
        /// TODO: Must be implemented</summary>
        /// <returns></returns>
        public override object Clone() {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Reports are deserialized and this constructor must be provided. 
        /// Consider implementing GetObjectData</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public Template(SerializationInfo info, StreamingContext context) {
        }
    }
}
